<template>
  <div>
    <van-nav-bar
      title="标题"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft"
    />
    <el-list>
      <el-list-item
          v-for="(announcement, index) in announcements"
          :key="index"
      >
        <div class="content" slot="content" @click="findOne(announcement.id)">
          <span class="span1">{{ announcement.title }}</span>
          <span class="span2">{{ announcement.uploadTime }}</span>
        </div>
      </el-list-item>
    </el-list>
  </div>
</template>

<script>

import axios from "axios";

export default {
  data() {
    return {
      announcements: []
    };
  },
  created() {
    this.findList()
  },
  methods: {
    // 查询所有
    findList(){
      axios.get('/announcement/list').then(res => {
        console.log(res)
        this.announcements = res.data
      })
    },
    findOne(id){
      this.$router.push({name: 'AnnouncementOne', params: {id: id}})
    },
    onClickLeft() {
      this.$router.push({path: '/shouyei'})
    },
  }
};
</script>
<style>
.content {
  height: 30px;
  margin: 10px;
  border-bottom: #d1d1d1 1px solid;
  .span1 {
    float: left;
  }
  .span2 {
    float: right;
  }
}
</style>
